function updateCounterfactual(theta,dataset,counterfactuals,lv,dfs)
    (cf_constants, cf_temps) = counterfactuals[2012]
    cf_temps.alphadraws[1:end-1,:] .= rand.()
    cc = dataset[2012][1]
    cap0 = [cf_constants.seats+cf_constants.sobrecupo; 0] #baseline, initial match
    II = size(lv.U,2)
    cap0_after = [cf_constants.seats; II]
    cap_efficient = [max.(cf_constants.seats, [sum(cc.enroll.==jj) for jj=1:size(lv.U,1)]); II]
    platform = .!(cf_constants.G8)
    equalalpha = let
        alphaOn = ones(4) .* sum([theta.alphaOn[k]*sum(cc.typ .== k) for k=1:4])/length(cc.typ)
        alphaOff = ones(4) .* sum([theta.alphaOff[k]*sum(cc.typ .== k) for k=1:4])/length(cc.typ)
        twoStageMatch(dfs,:equalalpha,lv,cap0.*[platform;false],cap0_after,alphaOn,alphaOff,platform,cf_constants,cf_temps,cc,theta)
    end
end

for (r,t) in enumerate(save_lv)
    year=2012
    println("updating counterfactuals: iter $t")
    JLD2.@load(outputpath*"/latentvariables$(year)_$t.mat",lv_out)
    theta_t = history[findfirst(save_params.==t)]
    df_means = c_means[r]
    df_individuals = c_individuals[r]
    df_byIter = c_byIter[r]
    dfs = (df_byIter, df_means, df_individuals)
    updateCounterfactual(theta_t,dataset,counterfactuals,lv_out,dfs)
end
